package com.herench.bs.handler;

import com.herench.bs.agent.IPersonAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * 患者住院身份验证通过
 * @author lij
 * @date: 2019/3/6
 */
@Component
@Handler(code = "100221",name="患者住院身份验证通过")
public class UserVerificationStateUpdateHandler extends AbstractMessageHandler {
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = null;
        String relatedUserId = requestMessage.getArgsPropertyStringValue("relatedUserId");
        String personId = requestMessage.getArgsPropertyStringValue("personId");
        String state = requestMessage.getArgsPropertyStringValue("state");
        String verificationState = requestMessage.getArgsPropertyStringValue("verificationState");
        Assert.isTrue(StringUtils.hasLength(relatedUserId), "relatedUserId 属性不能为空.");
        Assert.isTrue(StringUtils.hasLength(personId), "idCard 属性不能为空.");
        Assert.isTrue(StringUtils.hasLength(state), "state 属性不能为空.");
        Assert.isTrue(StringUtils.hasLength(verificationState), "verificationState 属性不能为空.");
        responseMessage = new ResponseMessage(requestMessage.getId());
        IPersonAgent agent = getCleverClinicContext().getApplicationContext().getBean(IPersonAgent.class);
        Map<String, Object> res = agent.UserVerificationStateUpdateAgent(relatedUserId,personId,state,verificationState);
        getPropertiesFromInvokerResultMap(responseMessage, res);
        responseMessage.setData(res);
        return responseMessage;
    }
}
